package com.pyk.controller;



import com.pyk.entity.CourseCategory;
import com.pyk.entity.Result;
import com.pyk.service.impl.CourseCategoryService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/coursecategory")
public class CourseCategoryController {
    @Resource
    private CourseCategoryService courseCategoryService;
    @PostMapping("/add")
    public Result add(@RequestBody CourseCategory courseCategory) {
        courseCategoryService.add(courseCategory);
        return Result.success();
    }
    @PostMapping("/update")
    public Result update(@RequestBody CourseCategory courseCategory) {
        courseCategoryService.update(courseCategory);
        return Result.success();
    }
    @DeleteMapping("/delete/{id}")
    public Result delete(@RequestBody Integer id) {
        courseCategoryService.deleteById(id);
        return Result.success();
    }
    @DeleteMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        courseCategoryService.deleteBatch(ids);
        return Result.success();
    }
    @GetMapping("/selectById/{id}")
    public Result selectById(@PathVariable Integer id) {
        CourseCategory courseCategory=courseCategoryService.selectById(id);
        return Result.success(courseCategory);
    }
    @GetMapping("/selectAll")
    public Result selectAll() {
        List<CourseCategory> list=CourseCategoryService.selectAll();
        return Result.success(list);
    }

}
